package kmu.lwl.controller;

import kmu.lwl.entiy.Login;
import kmu.lwl.imp.LoginDao;
import kmu.lwl.imp.impl.LoginDaoimpl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import java.util.Map;

public class LoginController extends ActionSupport {
    private Login login;

    public Login getLogin() {
        return login;
    }

    public void setLogin(Login login) {
        this.login = login;
    }

    @Override
    public String execute() throws Exception {
        LoginDao loginDao = new LoginDaoimpl();
        Login delidate = loginDao.delidate(login.getLoginName(), login.getLoginPassword());
        if (delidate!=null){
            Map session = ActionContext.getContext().getSession();
            session.put("user",delidate);
            return SUCCESS;
        }else{
            return "error";
        }
    }
}
